home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2001 May / may_2001.iso / intercd / root / Multimedia / ^DivX_Article / virtualdub / VirtualDub-source-1_4d / misc.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-20  |  1.6 KB  |  64 lines

  1. //    VirtualDub - Video processing and capture application
  2. //    Copyright (C) 1998-2001 Avery Lee
  3. //
  4. //    This program is free software; you can redistribute it and/or modify
  5. //    it under the terms of the GNU General Public License as published by
  6. //    the Free Software Foundation; either version 2 of the License, or
  7. //    (at your option) any later version.
  8. //
  9. //    This program is distributed in the hope that it will be useful,
  10. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. //    GNU General Public License for more details.
  13. //
  14. //    You should have received a copy of the GNU General Public License
  15. //    along with this program; if not, write to the Free Software
  16. //    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18. #include <ctype.h>
  19.  
  20. #include <wtypes.h>
  21. #include <mmsystem.h>
  22.  
  23. #include "misc.h"
  24.  
  25. long __declspec(naked) MulDivTrunc(long a, long b, long c) {
  26.     __asm {
  27.         mov eax,[esp+4]
  28.         imul dword ptr [esp+8]
  29.         idiv dword ptr [esp+12]
  30.         ret
  31.     }
  32. }
  33.  
  34. int NearestLongValue(long v, const long *array, int array_size) {
  35.     int i;
  36.  
  37.     for(i=1; i<array_size; i++)
  38.         if (v*2 < array[i-1]+array[i])
  39.             break;
  40.  
  41.     return i-1;
  42. }
  43.  
  44. bool isEqualFOURCC(FOURCC fccA, FOURCC fccB) {
  45.     int i;
  46.  
  47.     for(i=0; i<4; i++) {
  48.         if (tolower((unsigned char)fccA) != tolower((unsigned char)fccB))
  49.             return false;
  50.  
  51.         fccA>>=8;
  52.         fccB>>=8;
  53.     }
  54.  
  55.     return true;
  56. }
  57.  
  58. FOURCC toupperFOURCC(FOURCC fcc) {
  59.     return(toupper((unsigned char)(fcc>>24)) << 24)
  60.         | (toupper((unsigned char)(fcc>>16)) << 16)
  61.         | (toupper((unsigned char)(fcc>> 8)) <<  8)
  62.         | (toupper((unsigned char)(fcc    ))      );
  63. }
  64.